package tcp_net.mail.pop3.commands;

import tcp_net.mail.MailBoxFileManager;
import tcp_net.mail.pop3.commands.debug.DebugInfo;
import java.util.List;
import java.util.ArrayList;

/**
	This class provides a defined command to be executed
	@author J. Okuno
*/
public class RETR extends POP3Command 
{
	/**
		A message number
	*/
	private int msg;
	
	/**
		Init the class
		@param m a message number
		@param man a mailbox file manager
	*/
	public RETR(int m, MailBoxFileManager man) 
	{ 
		super(man);
		msg = m; 
	}
	
	/**
		This method executes a defined command
		@return a list of reply messages in a string format
	*/
	public List<String> execute() 
	{
		//Search the msg based on a msg num (but must not be delete marked)
		
		//if msg found
			//load the msg as a String
			String mail_msg = manager.getEntireMessage(msg-1);
			
			reply = new POP3ReplyMessage(true, "message follows");
			//return reply.execute() + "\n" + msg;
			reply_msgs.add(reply.execute().get(0));
			reply_msgs.add(mail_msg);
		
		//msg not found
		//	reply = new POP3ReplyMessage(false, "no such message");
		//	reply_msgs.add(reply.execute().get(0));
		
		return reply_msgs;
	}
}